<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>static file template</title>
    <link href="<%=staticRelativePath%>/normalize.css" rel="stylesheet" type="text/css" />
</head>
<style type="text/css">
    body {
        padding-top: 20px;
    }
    table {
        width: 100%;
    }

    table,
    th,
    td {
        border: 1px solid black;
        text-align: left;
    }
    tr {
        page-break-inside: avoid; 
    }

    .defect-count {
        background-color: #87898B;
        color: white;
        width: 80%;
    }

    .defect-level1 {
        background-color: #B43104;
        color: white;
        text-align:center;
    }
    .defect-level2 {
        background-color: #fdbb36;
        color: white;
        text-align:center;
    }
    .defect-level3 {
        background-color: #4dd5b3;
        color: white;
        text-align:center;
    }

    .defect-info {
        background-color: #b9b8bb;
        color: black;
    }

    .defect-index {
        text-decoration: underline;
    }

    .red-line {
        background-color: #e7e6e6;
        color: red;
    }
    .rule-title {
        font-weight: normal;
        font-size: medium;
    }
</style>

<body>
    <div>
        <% if (!ableReportCategory) {%>
        <h1>
            【<%= fileName%>】
        </h1>
        <br />
        <div>
            <% if (allRulesBySet) { %>
                <% allRulesBySet.forEach(setElement=> { %>
                    <% ["level1", "level2", "level3"].forEach(element => { %>
                        <% if (setElement.rules[element]) { %>
                            <% setElement.rules[element].forEach(levelElement=> { %>
                                <br />
                                <h2 class="rule-title">
                                    <%= setElement.ruleSetName%>
                                        <%= levelElement.ruleCode%>
                                </h2>
                                <table>
                                    <tr>
                                        <td class="defect-count">&nbsp;缺陷数量：<%= levelElement.total %>个</td>
                                        <% if (element === "level1") { %>
                                            <td class="defect-level1">
                                        <% } %>
                                        <% if (element === "level2") { %>
                                            <td class="defect-level2">
                                        <% } %>
                                        <% if (element === "level3") { %>
                                            <td class="defect-level3">
                                        <% } %>
                                         <%= levelElement.level %>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" class="defect-info">&nbsp;缺陷描述：<%=levelElement.name%>
                                        </td>
                                    </tr>
                                </table>
    
                                <% if (levelElement.defects) { %>
                                    <% levelElement.defects.forEach(defectElement=> { %>
                                        <div>
                                            <h3 class="defect-index">缺陷<%= defectElement.index%>
                                            </h3>
                                            <table>
                                                <tr>
                                                    <td>&nbsp;发生位置&nbsp;&nbsp; <%=defectElement.filePath%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>&nbsp;起始位置&nbsp;&nbsp; (<%=defectElement.locations.begin.line%>,
                                                            <%=defectElement.locations.begin.column%>)</td>
                                                </tr>
                                                <tr>
                                                    <td>&nbsp;终止位置&nbsp;&nbsp; (<%=defectElement.locations.end.line%>,
                                                            <%=defectElement.locations.end.column%>)</td>
                                                </tr>
                                                <% if (defectElement.lines) { %>
                                                    <% defectElement.lines.forEach(lineElement=> { %>
                                                        <% if (lineElement.red) { %>
                                                            <tr>
                                                                <td class="red-line">
                                                                    &nbsp;&nbsp;<%=lineElement.line%>&nbsp;&nbsp;
                                                                        <%=lineElement.content%>
                                                                </td>
                                                            </tr>
                                                            <% } else {%>
                                                                <tr>
                                                                    <td>
                                                                        &nbsp;&nbsp;<%=lineElement.line%>&nbsp;&nbsp;
                                                                            <%=lineElement.content%>
                                                                    </td>
                                                                </tr>
                                                                <% } %>
                                                                    <% }) %>
                                                                        <% } %>
                                                <tr>
                                                    <td>&nbsp;缺陷状态&nbsp;&nbsp; <%=defectElement.status%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>&nbsp;信息说明&nbsp;&nbsp; <%=defectElement.description%>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                        <% }) %>
                                            <% } %>
                                                <% }) %>
                                                    <% } %>
                    <% }) %>
                                                    <% }) %>
                                                        <% } %>
        </div>
        <%} else {%>
            <br />
            <h2 class="rule-title">
                <%= ruleSetName%> <%= ruleCode%>
            </h2>
            <div>
                <table>
                    <tr>
                        <td class="defect-count">&nbsp;缺陷数量：<%= total %>个</td>
                        <% if (level === 1) { %>
                            <td class="defect-level1">
                        <% } %>
                        <% if (level === 2) { %>
                            <td class="defect-level2">
                        <% } %>
                        <% if (level === 3) { %>
                            <td class="defect-level3">
                        <% } %>
                         <%= levelName %>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="defect-info">&nbsp;缺陷描述：<%= ruleName%>
                        </td>
                    </tr>
                </table>
                
                <% if (defects && defects.length > 0) { %>
                    <% defects.forEach(defectElement=> { %>
                        <div>
                            <h3 class="defect-index">缺陷<%= defectElement.index%>
                            </h3>
                            <table>
                                <tr>
                                    <td>&nbsp;发生位置&nbsp;&nbsp; <%=defectElement.filePath%>
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;起始位置&nbsp;&nbsp; (<%=defectElement.locations.begin.line%>,
                                            <%=defectElement.locations.begin.column%>)</td>
                                </tr>
                                <tr>
                                    <td>&nbsp;终止位置&nbsp;&nbsp; (<%=defectElement.locations.end.line%>,
                                            <%=defectElement.locations.end.column%>)</td>
                                </tr>
                                <% if (defectElement.lines) { %>
                                    <% defectElement.lines.forEach(lineElement=> { %>
                                        <% if (lineElement.red) { %>
                                            <tr>
                                                <td class="red-line">
                                                    &nbsp;&nbsp;<%=lineElement.line%>&nbsp;&nbsp;
                                                        <%=lineElement.content%>
                                                </td>
                                            </tr>
                                        <% } else {%>
                                                <tr>
                                                    <td>
                                                        &nbsp;&nbsp;<%=lineElement.line%>&nbsp;&nbsp;
                                                            <%=lineElement.content%>
                                                    </td>
                                                </tr>
                                                <% } %>
                                    <% }) %>
                                <% } %>
                                <tr>
                                    <td>&nbsp;缺陷状态&nbsp;&nbsp; <%=defectElement.status%>
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;信息说明&nbsp;&nbsp; <%=defectElement.description%>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    <% }) %>
                <% } %>
            </div>
        <% } %>
    </div>
</body>

</html>